import baseRequest from "@/axios/baseRequest"
import utils from "../utils/index"

export default {
  // 新增任务流
  insertTaskFlow(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/myTask/insertTaskFlow", params).then(data => {resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getList(params) {
    const temParams = utils.jsonToQuery(params)
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/myTask/pageTaskFlowInfo?" + temParams).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getTaskFlowDetail(params) {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/myTask/pageTaskFlowDetail?" + getParamStr(params)).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  updateTaskFlowInfo(params) {
    return new Promise((resolve, reject) => {
      baseRequest.put("/bigdata-pv-backend/myTask/updateTaskFlowInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  integrationStartDiagTask(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/myTask/integrationStartDiagTask", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
}
let getParamStr = (param) => {
  let str = ''
  for (let key in param) {
    if (param[key]) {
      str += [key] + '=' + param[key] + '&'
    }
  }
  return str
}
